﻿using System;

namespace FunctionalCLR.Core.Function.Arithmetics {
    public class SubNode : OperatorNode {
        public SubNode() {
            Value = "-";
            Precedence = 1;
        }

        public override object Accept(IVisitor visitor) {
            return visitor.Visit(this);
        }

        public override FuncNode GetReversedFunction(int index) {
            return new AddNode();
        }

        public override object Evaluate() {
            double lr = Convert.ToDouble(Left.Evaluate());
            double rr = Convert.ToDouble(Right.Evaluate());

            return (lr - rr).ToString();
        }
    }
}
